#pragma once
#include "Mutex.h"

namespace WinTools
{
	class CScopedMutex
	{
	public:
		/// <summary>
		/// Locks a CMutex within the current scope.
		/// </summary>
		/// <param name="mutex">The CMutex to lock</param>
		/// <returns></returns>
		CScopedMutex(CMutex &mutex, bool bTryLock = false);
		~CScopedMutex();

		/// <summary>
		/// Used to check if mutex is locked.
		/// </summary>
		/// <param name="b"></param>
		/// <returns></returns>
		bool operator==(bool b);

	private:
		CMutex &m_Mutex;
	};
}

